package com.burstly.lib.util.calendar;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

class Rfc3339Parser
{
  private static final String[] DATE_FORMATS;
  private static final Pattern RFC3339_PATTERN = Pattern.compile("\\d{4}-\\d{2}-\\d{2}(T|\\s)\\d{2}:\\d{2}(:\\d{2}(\\.\\d{1,3}|)|)([\\+-]\\d{2}:\\d{2}|Z)");

  static
  {
    DATE_FORMATS = new String[10];
    DATE_FORMATS[0] = "yyyy-mm-dd'T'HH:mmZ";
    DATE_FORMATS[1] = "yyyy-mm-dd' 'HH:mmZ";
    DATE_FORMATS[2] = "yyyy-mm-dd'T'HH:mm:ssZ";
    DATE_FORMATS[3] = "yyyy-mm-dd' 'HH:mm:ssZ";
    DATE_FORMATS[4] = "yyyy-mm-dd'T'HH:mm:ss.SZ";
    DATE_FORMATS[5] = "yyyy-mm-dd' 'HH:mm:ss.SZ";
    DATE_FORMATS[6] = "yyyy-mm-dd'T'HH:mm:ss.SSZ";
    DATE_FORMATS[7] = "yyyy-mm-dd' 'HH:mm:ss.SSZ";
    DATE_FORMATS[8] = "yyyy-mm-dd'T'HH:mm:ss.SSSZ";
    DATE_FORMATS[9] = "yyyy-mm-dd' 'HH:mm:ss.SSSZ";
  }

  static Date parseDateString(String paramString)
  {
    if (RFC3339_PATTERN.matcher(paramString).matches())
      return tryToParse(paramString);
    return null;
  }

  private static Date tryToParse(String paramString)
  {
    StringBuilder localStringBuilder = new StringBuilder(paramString);
    int i = -3 + localStringBuilder.length();
    if (localStringBuilder.lastIndexOf(":") == i)
      localStringBuilder.deleteCharAt(i);
    int j = -1 + localStringBuilder.length();
    if (localStringBuilder.lastIndexOf("Z") == j)
      localStringBuilder.replace(j, localStringBuilder.length(), "+0000");
    String str1 = localStringBuilder.toString();
    SimpleDateFormat localSimpleDateFormat = new SimpleDateFormat();
    String[] arrayOfString = DATE_FORMATS;
    int k = arrayOfString.length;
    int m = 0;
    while (m < k)
    {
      String str2 = arrayOfString[m];
      try
      {
        localSimpleDateFormat.applyPattern(str2);
        Date localDate = localSimpleDateFormat.parse(str1);
        return localDate;
      }
      catch (ParseException localParseException)
      {
        m++;
      }
    }
    return null;
  }
}

/* Location:           E:\android\Toy Defense 2_dex2jar.jar
 * Qualified Name:     com.burstly.lib.util.calendar.Rfc3339Parser
 * JD-Core Version:    0.6.2
 */